home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / lib / mkmf / RCS / mkmf.md,v < prev    next >
Encoding:
Text File  |  1992-06-17  |  10.0 KB  |  556 lines

  1. head     1.17;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    jhh:1.17; strict;
  6. comment  @@;
  7.  
  8.  
  9. 1.17
  10. date     91.04.03.21.48.08;  author rab;  state Exp;
  11. branches ;
  12. next     1.16;
  13.  
  14. 1.16
  15. date     90.11.05.05.41.25;  author jhh;  state Exp;
  16. branches ;
  17. next     1.15;
  18.  
  19. 1.15
  20. date     90.03.12.23.26.17;  author jhh;  state Exp;
  21. branches ;
  22. next     1.14;
  23.  
  24. 1.14
  25. date     90.01.15.18.49.22;  author tve;  state Exp;
  26. branches ;
  27. next     1.13;
  28.  
  29. 1.13
  30. date     90.01.15.18.48.40;  author tve;  state Exp;
  31. branches ;
  32. next     1.12;
  33.  
  34. 1.12
  35. date     89.07.18.16.01.36;  author ouster;  state Exp;
  36. branches ;
  37. next     1.11;
  38.  
  39. 1.11
  40. date     89.07.18.14.42.16;  author jhh;  state Exp;
  41. branches ;
  42. next     1.10;
  43.  
  44. 1.10
  45. date     89.04.06.21.40.12;  author jhh;  state Exp;
  46. branches ;
  47. next     1.9;
  48.  
  49. 1.9
  50. date     88.08.13.11.57.04;  author ouster;  state Exp;
  51. branches ;
  52. next     1.8;
  53.  
  54. 1.8
  55. date     88.07.20.13.34.32;  author douglis;  state Exp;
  56. branches ;
  57. next     1.7;
  58.  
  59. 1.7
  60. date     88.07.20.10.22.21;  author ouster;  state Exp;
  61. branches ;
  62. next     1.6;
  63.  
  64. 1.6
  65. date     88.06.17.16.27.51;  author ouster;  state Exp;
  66. branches ;
  67. next     1.5;
  68.  
  69. 1.5
  70. date     88.06.17.13.59.08;  author ouster;  state Exp;
  71. branches ;
  72. next     1.4;
  73.  
  74. 1.4
  75. date     88.06.06.17.23.20;  author ouster;  state Exp;
  76. branches ;
  77. next     1.3;
  78.  
  79. 1.3
  80. date     88.06.06.08.34.32;  author ouster;  state Exp;
  81. branches ;
  82. next     1.2;
  83.  
  84. 1.2
  85. date     88.06.05.11.39.07;  author ouster;  state Exp;
  86. branches ;
  87. next     1.1;
  88.  
  89. 1.1
  90. date     88.06.02.17.19.32;  author ouster;  state Exp;
  91. branches ;
  92. next     ;
  93.  
  94.  
  95. desc
  96. @@
  97.  
  98.  
  99. 1.17
  100. log
  101. @Add C++ support (Mike checking in for Bob).
  102. @
  103. text
  104. @#!/sprite/cmds/csh -f
  105. #
  106. # A script to generate the Makefile for a subdirectory that contains
  107. # machine-dependent sources and objects.  If ./Makefile.proto exists,
  108. # use it, else use a default prototype.
  109. #
  110. # We assume we were invoked from mkmf.  Parameters passed in from mkmf
  111. # through environment variables:
  112. #
  113. # Parameters passed in from mkmf as environment variables:
  114. #    MKMFDIR        directory containing prototype makefiles
  115. #    MAKEFILE    name of makefile to create
  116. #    PARENTDIR    name of parent directory (.. is fooled by symbolic
  117. #            links)
  118. #            
  119. # Variables generated here:
  120. #    dir        name of this subdirectory
  121. #    machine        name of machine type for this directory (e.g. "sun3")
  122. #    pref        prefix pattern that files must match to be included
  123. #    makefile    name of the makefile to create
  124. #    proto        name of prototype makefile to use to create $makefile
  125. #
  126.  
  127. #
  128. # Argument processing.  (Generalized form, even though just one flag so far.)
  129. #
  130. while ($#argv >= 1)
  131.     if ("$1" == '-x') then
  132.     set echo
  133.     endif
  134.     shift
  135. end
  136.  
  137. set machine=$cwd:t
  138. set machine=$machine:r
  139. set pref='[0-9a-z_A-Z]'
  140.  
  141. if ($?MAKEFILE) then
  142.     set makefile=$MAKEFILE
  143. else
  144.     set makefile=Makefile
  145. endif
  146.  
  147. if (-e $makefile.proto) then
  148.     set proto=$makefile.proto
  149. else
  150.     set proto="${MKMFDIR}/Makefile.md"
  151. endif
  152.  
  153. set dir=$cwd:t
  154. set machine=$dir:r
  155. set parent=$cwd:h
  156. set parent=$parent:t
  157. echo "Generating $makefile for $parent/$dir using $proto"
  158.  
  159. if ($?PARENTDIR) then
  160.     set parentdir=$PARENTDIR
  161. else
  162.     set parentdir=..
  163. endif
  164.  
  165. #
  166. # First figure out what's here by way of .c, .y, .l, .s, .p, .h
  167. # and .o files.  For sources, look both in this directory and in
  168. # the parent (machine-independent) directory.
  169. # If any one doesn't have any members, it'll contain the original
  170. # pattern (b/c of nonomatch). We want it to be empty, though, so
  171. # we reset it.
  172. #
  173. set nonomatch
  174. set tmp=( ${pref}*.{c,y,l,s,p,cc} )
  175. #
  176. # Check to see if there were any sources.  The first check (size == 1)
  177. # is only necessary because the second check will cause an error if
  178. # allSrcs contains more than 1024 bytes.
  179. #
  180. if ($#tmp == 1) then
  181.     if ("$tmp" == "${pref}*.{c,y,l,s,p,cc}") set tmp=()
  182. endif
  183. set srcs=()
  184. foreach i ($tmp)
  185.     set srcs=($srcs $dir/$i)
  186. end
  187. set tmp=( ${parentdir}/${pref}*.{c,y,l,s,p,cc} )
  188. if ($#tmp == 1) then
  189.     if ("$tmp" == "${parentdir}/${pref}*.{c,y,l,s,p,cc}") set tmp=()
  190. endif
  191.  
  192. foreach i ($tmp:gt)
  193.     if (! -e $i) then
  194.     set srcs = ($srcs $i)
  195.     endif
  196. end
  197.  
  198. set tmp=( ${pref}*.h )
  199. if ($#tmp == 1) then
  200.     if ("$tmp" == "${pref}*.h") set tmp=()
  201. endif
  202. set hdrs=()
  203. foreach i ($tmp)
  204.     set hdrs=($hdrs $dir/$i)
  205. end
  206. set tmp=( ${parentdir}/${pref}*.h )
  207. if ($#tmp == 1) then
  208.     if ("$tmp" == "${parentdir}/${pref}*.h") set tmp=()
  209. endif
  210. foreach i ($tmp:gt)
  211.     if (! -e $i) then
  212.     set hdrs = ($hdrs $i)
  213.     endif
  214. end
  215.  
  216. set tmp=( ${parent}*.h )
  217. if ($#tmp == 1) then
  218.     if ("$tmp" == "${parent}*.h") set tmp=()
  219. endif
  220. set pubHdrs=()
  221. foreach i ($tmp)
  222.     set pubHdrs=($pubHdrs $dir/$i)
  223. end
  224. set pubHdrs=(`echo $pubHdrs | sed -e "s/[^ ]*Int.h//g"`)
  225.  
  226. #
  227. # Find miscellaneous files needed for builds (Makefiles, etc).
  228. #
  229. set tmp=( md.mk md.mk.sed dependencies.mk )
  230. set instfiles=()
  231. foreach i ($tmp)
  232.     if (-e $i) then
  233.     set instfiles=($instfiles $dir/$i)
  234.     endif
  235. end
  236. set tmp=( Makefile local.mk Makefile.sed Makefile.ex tags TAGS )
  237. foreach i ($tmp)
  238.     if (-e ${parentdir}/$i) then
  239.     set instfiles = ($instfiles $i)
  240.     endif
  241. end
  242.  
  243.  
  244. rm -f version.o
  245. set tmp=( ${pref}*.o )
  246. #
  247. # Check to see if there were any object files.  The first check (size == 1)
  248. # is only necessary because the second check will cause an error if
  249. # tmp contains more than 1024 bytes.
  250. #
  251. if ($#tmp == 1) then
  252.     if ("$tmp" == "${pref}*.o") set tmp=()
  253. endif
  254. set objs=()
  255. foreach i ($tmp)
  256.     set objs=($objs $dir/$i)
  257. end
  258. unset nonomatch
  259.  
  260. #
  261. # Merge in any .o files that can be created from local source files but don't
  262. # exist yet. In addition, figure out which .o files may be safely removed
  263. # during a "make clean" and store them in RmOfiles.
  264. #
  265. set RmOfiles=""
  266. if ($#srcs != 0) then
  267.     foreach file ($srcs)
  268.         set file=$file:t
  269.         set file=$file:r.o
  270.         set RmOfiles=($RmOfiles $dir/$file)
  271.         if (! -e $file) set objs=($objs $dir/$file)
  272.     end
  273. endif
  274.  
  275. set sacredObjs=""
  276. foreach file ($objs)
  277.     set tmp = $file:r
  278.     echo $RmOfiles | grep $file > /dev/null
  279.     if ($status && ($tmp:t != $parentdir:t)) then
  280.     set sacredObjs = ($sacredObjs $file)
  281.     echo "WARNING: file $file does not have a source file"
  282.     endif
  283. end
  284.  
  285. #
  286. # Use sed to substitute various interesting things into the prototype
  287. # makefile. The code below is a bit tricky because some of the variables
  288. # being substituted in can be very long:  if the substitution is passed
  289. # to sed with "-e", the entire variable must fit in a single shell argument,
  290. # with a limit of 1024 characters.  By generating a separate script file
  291. # for the very long variables, the variables get passed through (to the
  292. # script file) as many arguments, which gets around the length problem.
  293. #
  294.  
  295. rm -f mkmf.tmp.sed
  296. echo s,"@@(SRCS)",$srcs,g > mkmf.tmp.sed
  297. echo s,"@@(OBJS)",$objs,g >> mkmf.tmp.sed
  298. echo s,"@@(CLEANOBJS)",$RmOfiles,g >> mkmf.tmp.sed
  299. echo s,"@@(HDRS)",$hdrs,g >> mkmf.tmp.sed
  300. echo s,"@@(INSTFILES)",$instfiles,g >> mkmf.tmp.sed
  301. echo s,"@@(SACREDOBJS)",$sacredObjs,g >> mkmf.tmp.sed
  302.  
  303. cat $proto | sed -f mkmf.tmp.sed \
  304.     -e "s,@@(PUBHDRS),$pubHdrs,g" \
  305.     -e "s,@@(TEMPLATE),$proto,g" \
  306.     -e "s,@@(DATE),`date`,g" > $makefile
  307. rm -f mkmf.tmp.sed
  308. @
  309.  
  310.  
  311. 1.16
  312. log
  313. @Warn if an object file does not have a source file.
  314. @
  315. text
  316. @d72 1
  317. a72 1
  318. set tmp=( ${pref}*.[cylsp] )
  319. d79 1
  320. a79 1
  321.     if ("$tmp" == "${pref}*.[cylsp]") set tmp=()
  322. d85 1
  323. a85 1
  324. set tmp=( ${parentdir}/${pref}*.[cylsp] )
  325. d87 1
  326. a87 1
  327.     if ("$tmp" == "${parentdir}/${pref}*.[cylsp]") set tmp=()
  328. @
  329.  
  330.  
  331. 1.15
  332. log
  333. @sets a variable with names of object files for which there
  334. are no sources
  335. @
  336. text
  337. @d175 1
  338. d177 1
  339. a177 1
  340.     if ($status) then
  341. d179 1
  342. d182 1
  343. @
  344.  
  345.  
  346. 1.14
  347. log
  348. @allow source files to start with digits
  349. @
  350. text
  351. @d124 18
  352. d173 7
  353. d195 2
  354. @
  355.  
  356.  
  357. 1.13
  358. log
  359. @*** empty log message ***
  360. @
  361. text
  362. @d36 1
  363. a36 1
  364. set pref='[a-z_A-Z]'
  365. @
  366.  
  367.  
  368. 1.12
  369. log
  370. @Require module prefix for a header to be considered public.
  371. @
  372. text
  373. @d126 8
  374. a133 1
  375. if ("$tmp" == "${pref}*.o") set tmp=()
  376. d169 1
  377. a171 1
  378.     -e "s,@@(HDRS),$hdrs,g" \
  379. @
  380.  
  381.  
  382. 1.11
  383. log
  384. @allow there to be both machine dependent and independent versions of files
  385. @
  386. text
  387. @a100 1
  388. set pubHdrs=()
  389. a103 1
  390. set pubHdrs=(`echo $hdrs | sed -e "s/[^ ]*Int.h//g"`)
  391. a107 1
  392.  
  393. d113 10
  394. @
  395.  
  396.  
  397. 1.10
  398. log
  399. @added abilty to make specific machine types
  400. @
  401. text
  402. @a88 1
  403. set srcs=($srcs $tmp:gt)
  404. d90 6
  405. d110 6
  406. a115 1
  407. set hdrs=($hdrs $tmp:gt)
  408. @
  409.  
  410.  
  411. 1.9
  412. log
  413. @Added "-x" switch.
  414. @
  415. text
  416. @d13 2
  417. d56 6
  418. d85 1
  419. a85 1
  420. set tmp=( ../${pref}*.[cylsp] )
  421. d87 1
  422. a87 1
  423.     if ("$tmp" == "../${pref}*.[cylsp]") set tmp=()
  424. d92 3
  425. a94 1
  426. if ("$tmp" == "${pref}*.h") set tmp=()
  427. d101 4
  428. a104 2
  429. set tmp=( ../${pref}*.h )
  430. if ("$tmp" == "../${pref}*.h") set tmp=()
  431. @
  432.  
  433.  
  434. 1.8
  435. log
  436. @fixed a typo causing each file to be included twice in list 
  437. of file names.
  438. @
  439. text
  440. @d21 11
  441. @
  442.  
  443.  
  444. 1.7
  445. log
  446. @Add code to be more careful about long lists of source files.
  447. @
  448. text
  449. @d68 1
  450. a68 1
  451.     if ("$tmp" == "${pref}*.[cylsp]") set tmp=()
  452. @
  453.  
  454.  
  455. 1.6
  456. log
  457. @Changes to handle directories with many many files.
  458. @
  459. text
  460. @d54 8
  461. a61 1
  462. if ("$tmp" == "${pref}*.[cylsp]") set tmp=()
  463. d67 3
  464. a69 1
  465. if ("$tmp" == "../${pref}*.[cylsp]") set tmp=()
  466. d99 1
  467. a99 1
  468. if ("$srcs" != "") then
  469. @
  470.  
  471.  
  472. 1.5
  473. log
  474. @Wasn't getting pubhdrs right.
  475. @
  476. text
  477. @a20 1
  478.  
  479. d99 16
  480. a114 2
  481. cat $proto | sed \
  482.     -e "s,@@(SRCS),$srcs,g" \
  483. a116 2
  484.     -e "s,@@(OBJS),$objs,g" \
  485.     -e "s,@@(CLEANOBJS),$RmOfiles,g" \
  486. d119 1
  487. @
  488.  
  489.  
  490. 1.4
  491. log
  492. @Generate MDPUBHDRS to identify machine-dependent public headers.
  493. @
  494. text
  495. @a69 3
  496.     if ("$i" !~ " *Int.h") then
  497.         set pubHdrs=($pubHdrs $dir/$i)
  498.     endif
  499. d71 1
  500. @
  501.  
  502.  
  503. 1.3
  504. log
  505. @Print out name of actual makefile, not "Makefile".
  506. @
  507. text
  508. @d67 1
  509. d70 3
  510. d105 1
  511. @
  512.  
  513.  
  514. 1.2
  515. log
  516. @Various revisions to generate Makefiles for multi-directory
  517. libraries with multiple target machines.
  518. @
  519. text
  520. @d42 1
  521. a42 1
  522. echo "Generating a Makefile for $parent/$dir using $proto"
  523. @
  524.  
  525.  
  526. 1.1
  527. log
  528. @Initial revision
  529. @
  530. text
  531. @d3 2
  532. a4 2
  533. # A script to generate the Makefile for a machine-dependent subdirectory
  534. # of the source directory for a command.  If ./Makefile.proto exists,
  535. d7 2
  536. a8 3
  537. # We assume we were invoked from mkmf, thus we don't need to alter the
  538. # path, and MKMFDIR is in the environment to tell us where to find prototype
  539. # makefiles, etc.
  540. d15 1
  541. d35 1
  542. a35 1
  543.     set proto="${MKMFDIR}/Makefile.command.md"
  544. d40 3
  545. a42 3
  546. set dir2=$cwd:h
  547. set dir2=$dir2:t
  548. echo "Generating a Makefile for $dir2/$dir using $proto"
  549. d45 3
  550. a47 3
  551. # First figure out what's there by way of .c, .y, .l, .s, .p, .h
  552. # and .o files.  For sources, look both in this directory and in the
  553. # parent (machine-independent) directory.
  554. @
  555.